package com.tanhua.dubbo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.domain.db.AnalysisByDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {
    @Select("select sum(num_registered) num from tb_analysis_by_day")
    Long numCumulativeUsers();

    @Select("select sum(num_active) num from tb_analysis_by_day where record_date >= #{passTime}")
    Long numActivePass(String passTime);

    @Select("select num_registered num from tb_analysis_by_day where record_date = #{time}")
    Long numNewUsers(String time);

    @Select("select num_login num from tb_analysis_by_day where record_date = #{time}")
    Long numLoginTimesToday(String time);

    @Select("select num_active num from tb_analysis_by_day where record_date = #{time}")
    Long numActiveUsersToday(String time);

    @Select("select record_date, ${col} from tb_analysis_by_day where record_date <= #{end} and record_date >= #{start}")
    List<AnalysisByDay> selectByDateAndType(@Param("start") String start, @Param("end") String end, @Param("col") String col);
}
